 <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 基础表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <!--<link rel="stylesheet" type="text/css" href="__PUBLIC__/common/css/Hui-iconfont/1.0.7/iconfont.css"/>-->
    <style>
        .page{height:30px;}
        .page a,.pagin span{border:1px solid #ccc;padding:5px;margin-top:10px;clear:both;margin-left:10px;}
        .page span{width:20px;float:left;text-align: center;}
        .page a:hover{color:#f0580c;border-color:#f0580c;}
        .Hui-iconfont,.fa-mail-forward{font-size:16px;}
        .num{color:darkred;margin-right:10px;}
        .download{float:right;}
        .rebate{float:left;margin:-8px 0px 0px 50px;}
        .fa{font-size:16px;}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>小时结算</h5>
                        <if condition="($return_operation_log eq '') or ($return_operation_log eq null)">
                            <button type="button" class="btn btn-outline btn-primary rebate" onclick="settlement(this)">结算</button>
                            <else/>
                            <button type="button" class="btn btn-outline btn-primary rebate" disabled>结算</button>
                        </if>
                        <a class="download" href="__URL__/downloadAll/account/{$account}/from/{$from}/to/{$to}"><i class="fa fa-download"></i>下载>></a>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form method="post" action="__URL__/settlementLog" id="searchForm">
                                <div class="col-sm-4 m-b-xs">
                                    时间 ： <input type="text" id="from" value="{$from}" name="from" class="laydate-icon form-control layer-date" style="width:40%;display:inline-block;"> -
                                    <input type="text" id="to" value="{$to}" name="to" class="laydate-icon form-control layer-date" style="width:40%;display:inline-block;">
                                </div>
                                <div class="col-sm-2">
                                    <div class="input-group">
                                        <input type="text" placeholder="请输入MT4账号" value="{$account}" name="account" class="input-sm form-control">
                                        <span class="input-group-btn"><button type="submit" class="btn btn-sm btn-primary">搜索</button></span>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>ID</th>
                                        <!--<th>账户余额</th>-->
                                        <th>开始时间</th>
                                        <th>结束时间</th>
                                        <th>Boss账号</th>
                                        <th>用户总投资</th>
                                        <th>结算</th>
                                        <th>用户实际收益</th>
                                        <th>IB返佣</th>
                                        <th>其他费用</th>
                                        <th>结算对冲</th>
                                        <th>现余额</th>
                                        <th>状态</th>
                                        <th>操作时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <volist name="list" id="vo">
                                    <tr>
                                        <td><input type="checkbox" class="i-checks" name="input[]"></td>
                                        <td>{$vo.id}</td>
                                        <!--<td>{$vo.balance}</td>-->
                                        <td>{$vo.from}</td>
                                        <td>{$vo.to}</td>
                                        <td>{$vo.account} ({$vo.abbreviation})</td>
                                        <td>{$vo.volume_all}</td>
                                        <td>{$vo.settlement}</td>
                                        <td>{$vo.profit_all}</td>
                                        <td>{$vo.rebate}</td>
                                        <td>{$vo.other_desc} ： {$vo.other_expenses}</td>
                                        <td>{$vo.finall}</td>
                                        <td>{$vo.now_balance}</td>
                                        <td><if condition="$vo.status eq 1">
                                            <span style="color:green;">成功</span>
                                        <else/>
                                            <if condition="$vo.finall eq 0">
                                                <span style="color:green;">成功</span>
                                            <else/>
                                                <span style="color:red;">失败 : {$vo.status}</span>
                                            </if>
                                        </if>
                                        </td>
                                        <td>{$vo.time|date='Y-m-d H:i:s',###}</td>
                                        <td class="td-manage">
                                            <if condition="($vo.status neq 1) and ($vo.finall neq 0)">
                                                <a style="text-decoration:none" onclick="updateSettlement('{$vo.id}')" title="重新结算">
                                                    <i class="fa fa-mail-forward"></i>
                                                </a>&nbsp;
                                            </if>
                                            <a style="text-decoration:none" href="__URL__/downloadTransaction/id/{$vo.id}" title="导出交易明细">
                                                <i class="fa fa-download"></i>
                                            </a>&nbsp;
                                            <a style="text-decoration:none" onclick="otherExpenses('其他费用','__URL__/otherExpensesView/id/{$vo.id}','800','400')" title="其他费用">
                                                <i class="fa fa-plus-square"></i>
                                            </a>&nbsp;
                                            <a style="text-decoration:none" onclick="deleteSettlementLog('{$vo.id}')" title="删除">
                                                <i class="fa fa-trash"></i>
                                            </a>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                            <div class="page">{$page}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <include file="Index/common_js"/>
    <!-- Peity -->
    <script src="__PUBLIC__/admin/js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
    <script src="__PUBLIC__/common/js/layer_show.js"></script>
    <!-- iCheck -->
    <script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/layer/laydate/laydate.js"></script>
    <script>
        var index;
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });

            laydate({
                elem: '#from', /*目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'*/
                event: 'focus', /*响应事件。如果没有传入event，则按照默认的click*/
                //format: 'YYYY-MM-DD hh:mm:ss',
            });
            laydate({
                elem: '#to', /*目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'*/
                event: 'focus' /*响应事件。如果没有传入event，则按照默认的click*/
            });
        });

        function otherExpenses(title, url, w, h){/*添加其他费用*/
            layer_show(title, url, w, h);
        }

        function updateSettlement(id){/*结算失败-重新结算*/
            index = layer.load();
            $.ajax({
                type:"POST",
                url:"__URL__/updateSettlement",
                dataType:'json',
                data:{id:id},
                success:function(data){
                    //console.log(data);return;
                    //alert(JSON.stringify(data));return;
                    layer.close(index);
                    if(data.status ==1){
                        layer.msg(data.msg,{icon: 1, time: 2000});
                        location.reload();
                    }else{
                        layer.msg(data.msg,{icon: 2, time: 2000});
                    }
                },error:function(err){
                    layer.msg('网络错误',{icon: 2, time: 2000});
                    //console.log(err);
                }
            });
        }

        function settlement(obj){/*小时结算*/
            $(obj).parent('.ibox-title').html('<h5>小时结算</h5><button type="button" class="btn btn-outline btn-default rebate" disabled>请稍后...</button>');
            return;
            index = layer.load();
            $.ajax({
                type:"POST",
                url:"__URL__/settlement",
                dataType:'json',
                data:{},
                success:function(data){
                    console.log(data);
                    //alert(JSON.stringify(data));return;
                    layer.close(index);
                    if(data.status ==1){
                        layer.msg(data.msg,{icon: 1, time: 2000});
                        location.href='__URL__/downloadSettlementLog/from/'+data.from+'/to/'+data.to;
                    }else{
                        layer.msg(data.msg,{icon: 2, time: 2000});
                    }
                },error:function(err){
                    layer.msg('网络错误',{icon: 2, time: 2000});
                    //console.log(err);
                }
            });
        }

        function deleteSettlementLog(id){/*删除结算*/
            layer.confirm("您确定要删除吗?",function(){
                var load=layer.load();
                $.ajax({
                    type:"POST",
                    url:"__URL__/deleteSettlementLog",
                    dataType:'json',
                    data:{id:id},
                    success:function(data){
                        //console.log(data);
                        layer.close(load);
                        //alert(JSON.stringify(data));return;
                        if(data.status ==1){
                            layer.msg(data.msg, {icon: 1, time: 2000});
                            location.reload();
                        }else if(data.status ==-1){
                            layer.alert(data.msg);
                        }else{
                            layer.msg(data.msg, {icon: 2, time: 2000});
                        }
                    },error:function(err){
                        layer.msg('网络错误',{icon: 2, time: 2000});
                        //console.log(err);
                    }
                });
            })
        }
    </script>
</body>
</html>
